package com.planet.biz;

import com.planet.db.dao.UserMapper;
import com.planet.db.model.User;
import com.planet.facade.UserBiz;
import com.planet.query.UserQuery;
import com.planet.utils.CommonConverter;
import com.planet.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by jiayazi on 17/11/15.
 */
@Component("userBiz")
public class UserBizImpl implements UserBiz{
    @Autowired
    UserMapper userMapper;

    @Override
    public int insertSelective(UserQuery userQuery) {
        return userMapper.insertSelective(userQuery);
    }

    @Override
    public UserVO selectByPrimaryKey(String userId) {
        User user =  userMapper.selectByPrimaryKey(userId);
        UserVO userVO = new UserVO();
        CommonConverter.convert(user, userVO);
        return userVO;
    }

    @Override
    public String checkUserName(String userName) {
        return userMapper.checkUserName(userName);
    }

    @Override
    public String login(String userName, String passWord) {
        return userMapper.login(userName,passWord);
    }
}
